<?php
Class CategorieBiomedDAO
{
	public $connexion;

	public function __construct()
	{
		try {
			$this->connexion = new PDO("mysql:host=".SERVEUR_MYSQL.";dbname=".BASE.";charset=utf8", UTILISATEUR, M2P);
		}
		catch(PDOException $e)
		{
			echo "Erreur : ".$e->getMessage();
			die();
		}
	}


	public function rechercher_categorie($idcategorie = null, $idtypecategorie = null)
	{
		$query = "SELECT * "
		."FROM categorie_biomed WHERE 1 ";
		if ($idcategorie != null){
			$query .= " AND idcategorie = :idcategorie ";
		}
		if ($idtypecategorie != null){
			$query .= " AND idtypecategorie = :idtypecategorie ";
		}
		$requette_preparee = $this->connexion->prepare($query);
		if ($idcategorie != null){
			$requette_preparee->bindValue(":idcategorie" , $idcategorie, PDO::PARAM_INT);
		}
		if ($idtypecategorie != null){
			$requette_preparee->bindValue(":idtypecategorie" , $idtypecategorie, PDO::PARAM_INT);
		}
		$requette_preparee->execute();
		$categories= $requette_preparee->fetchAll(PDO::FETCH_CLASS,'CategorieBiomed');
		return  $categories;

	} // rechercher_categorie
	public function recherche_combo()
	{
		$query = "SELECT * "
				."FROM categorie_biomed WHERE 1 ";
		$requette_preparee = $this->connexion->prepare($query);
		$requette_preparee->execute();
		$categories= $requette_preparee->fetchAll(PDO::FETCH_CLASS,'CategorieBiomed');
		return  $categories;
	
	} // rechercher_categorie

} // CategorieBiomedDAO



?>
